using System;
using System.Collections;

namespace HossMvp.Core
{
    public class ActionResult
    {
        public Hashtable Data { get; private set; }

        public ActionResult()
        {
            this.Data = new Hashtable();
        }

        public T Get<T>(string name)
        {
            var value = this.Data[name];
            var result = (T)Convert.ChangeType(value, typeof(T));
            return result;
        }

        public void Set(string name, object value)
        {
            this.Data[name] = value;
        }
    }

    public static class ActionResultFluentApi
    {
        public static ActionResult WithProperty(this ActionResult result, string name, object value)
        {
            result.Data[name] = value;
            return result;
        }
    }
}